<template>
  <div id="app">
    <!-- 头部 -->
    <van-nav-bar :title="title" left-text="返回" left-arrow @click.native="goback" />
    <!-- 内容区域 -->
    <router-view></router-view>
    <!-- 底部 -->
    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="/home"></van-tabbar-item>
      <van-tabbar-item icon="friends-o" to="/friend"></van-tabbar-item>
      <van-tabbar-item icon="cart-o" info="6" to="/carts"></van-tabbar-item>
      <van-tabbar-item icon="search" to="/search"></van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>

export default {
  name: 'app',
  data () {
    return {
      title: this.$route.meta.title,
      active: 2
    }
  },
  methods: {
    goback () {
      this.$router.go(-1)
    }
  },
  watch: {
    // 监视路由信息的变化
    '$route.meta.title' (newW, oldw) {
      this.title = newW;
    }
  }
};
</script>

<style scoped>
</style>
